alert('SceneScene3.js loaded');
//GESTION TEXT ///
/*
var CurrentScene="Scene3";
var _count = 1;
var type="";
var compteur= 0; // Compteur ligne 
var scene = "3/3-a.json";  //Nom de la scene initiatrice */



var PosDialButton;
var cpt;

function SceneScene3() {

};

SceneScene3.prototype.initialize = function () {
	alert("SceneScene3.initialize()");
	// this function will be called only once when the scene manager show this scene first time
	// initialize the scene controls and styles, and initialize your variables here
	// scene HTML and CSS will be loaded before this function is called	

	
	$('#drapTh').sfImage({
		src:'images/Enigmas/th.png'
	});
	$('#drapCost').sfImage({
		src:'images/Enigmas/cr.png'
	});
	$('#drapCor').sfImage({
		src:'images/Enigmas/kp.png'
	});
	
	
	$('#drap01').css("left",ExtractX(2,2)+"px");
	$('#drap01').css("top",ExtractY(2,2)+"px");
	$('#drap01').css("visibility","hidden");
	
	$('#drap02').css("left",ExtractX(2,4)+"px");
	$('#drap02').css("top",ExtractY(2,4)+"px");
	$('#drap02').css("visibility","hidden");
	
	$('#drap03').css("left",ExtractX(2,6)+"px");
	$('#drap03').css("top",ExtractY(2,6)+"px");
	$('#drap03').css("visibility","hidden");
	
	$('#SelectDrap').css("visibility","hidden");
	
	
	
	/*
	alert(" **** " + $('#drapCost').css("left") + " **** ");
	alert(" **** " + $('#drapCost').css("top") + " **** ");
	alert("--/-/-/-/-/-/-/-/-/-/-/-/");
	alert(" **** " + $('#drapTh').css("left") + " **** ");
	alert(" **** " + $('#drapTh').css("top") + " **** ");
	alert("/--/-/-/-/-/-/-/-/-/-/-/-");
	alert(" **** " + $('#drapCor').css("left") + " **** ");
	alert(" **** " + $('#drapCor').css("top") + " **** ");
	*/
};

SceneScene3.prototype.handleShow = function (data) {
	alert("SceneScene3.handleShow()");
	// this function will be called when the scene manager show this scene
	cpt=0;
	IdScene ="1";
	CurrentScene = "Scene3";
	SceneReset(CurrentScene,-1);	
	HandleSelectDrap();
	
};

SceneScene3.prototype.handleHide = function () {
	alert("SceneScene3.handleHide()");
	// this function will be called when the scene manager hide this scene
	scene="";
};

SceneScene3.prototype.handleFocus = function () {
	alert("SceneScene3.handleFocus()");
	// this function will be called when the scene manager focus this scene
};

SceneScene3.prototype.handleBlur = function () {
	alert("SceneScene3.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
};

SceneScene3.prototype.handleKeyDown = function (keyCode) {
	alert("SceneScene3.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	switch (keyCode) {
		case sf.key.LEFT:
			alert("LEFT");
			if(TypeEvent == "enigme"){
				alert("OK GO LEFT");
				PosDialButton--;
				HandleSelectDrap();
			}
			break;
		case sf.key.RIGHT:
			alert("RIGHT");
			if(TypeEvent == "enigme"){
				alert("OK GO RIGHT");
				PosDialButton++;
				HandleSelectDrap();
			}
			break;
		case sf.key.UP:
			break;
		case sf.key.DOWN:
			break;
		case sf.key.ENTER:
			
			alert("========================== "+TypeEvent+" ===========================");
			if(TypeEvent != "enigme"){
				
				$('#drap01').css("visibility","hidden");
				$('#drap02').css("visibility","hidden");
				$('#drap03').css("visibility","hidden");
				//Function Enter
				Enter();

			}else{
				$('#drap01').css("visibility","visible");
				$('#drap02').css("visibility","visible");
				$('#drap03').css("visibility","visible");
				$('#SelectDrap').css("visibility","visible");
				
				cpt++;
				alert("haaaaaaaaaaaaaaaa -- "+cpt+" -- aaaaaaaaaaaaaaaaaah");
				if (PosDialButton == 0 & cpt>1){
					scene = '1/3/3-b.json';
					TypeEvent = "";
					compteur= 0;
					OneTime();
				}else if (PosDialButton == 1 & cpt>1){
					scene = '1/3/3-c.json';
					compteur= 0;
					OneTime();
				}else if (PosDialButton == 2 & cpt>1){
					scene = '1/3/3-d.json';
					compteur= 0;
					OneTime();
				}
				
			}
			break;
		case sf.key.RETURN:
			event.preventDefault();
			sf.scene.hide('Scene3');
			sf.scene.show('MapQueensPark');
			sf.scene.focus('MapQueensPark');
			break;
		default:
			alert("handle default key event, key code(" + keyCode + ")");
			break;
	}
};



function HandleSelectDrap(){
	if (PosDialButton == 0){
		$('#SelectDrap').css("left",ExtractX(2,2)+"px");
		$('#SelectDrap').css("top",ExtractY(2,2)+"px");
		//alert("*/*/*/*/*/*/*/*/*/ "+$('#SelectDrap').css("left")+" - "+$('#SelectDrap').css("top")+" /*/*/*/*/*/*/*/*/*/*/");
	}else if (PosDialButton == 1){
		$('#SelectDrap').css("left",ExtractX(2,4)+"px");
		$('#SelectDrap').css("top",ExtractY(2,4)+"px");
		//alert("*/*/*/*/*/*/*/*/*/ "+$('#SelectDrap').css("left")+" - "+$('#SelectDrap').css("top")+" /*/*/*/*/*/*/*/*/*/*/");		
	}else if (PosDialButton == 2){
		$('#SelectDrap').css("left",ExtractX(2,6)+"px");
		$('#SelectDrap').css("top",ExtractY(2,6)+"px");
		//alert("*/*/*/*/*/*/*/*/*/ "+$('#SelectDrap').css("left")+" - "+$('#SelectDrap').css("top")+" /*/*/*/*/*/*/*/*/*/*/");
	}else if (PosDialButton < 0){
		PosDialButton = 2;
		$('#SelectDrap').css("left",ExtractX(2,6)+"px");
		$('#SelectDrap').css("top",ExtractY(2,6)+"px");
		//alert("*/*/*/*/*/*/*/*/*/ "+$('#SelectDrap').css("left")+" - "+$('#SelectDrap').css("top")+" /*/*/*/*/*/*/*/*/*/*/");
	}else if (PosDialButton > 2){
		PosDialButton = 0;
		$('#SelectDrap').css("left",ExtractX(2,2)+"px");
		$('#SelectDrap').css("top",ExtractY(2,2)+"px");
		//alert("*/*/*/*/*/*/*/*/*/ "+$('#SelectDrap').css("left")+" - "+$('#SelectDrap').css("top")+" /*/*/*/*/*/*/*/*/*/*/");
	}
}
